home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWDebug / Include / FWDbgStr.h next >
Encoding:
Text File  |  1995-11-08  |  6.1 KB  |  247 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWDbgStr.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWENVDEF_H
  11. #include "FWEnvDef.h"
  12. #endif
  13.  
  14. #if !defined(FWDBGSTR_H) && defined(FW_DEBUG)
  15. #define FWDBGSTR_H
  16.  
  17. #include <stddef.h>
  18.  
  19. #ifndef FWSTDDEF_H
  20. #include "FWStdDef.h"
  21. #endif
  22.  
  23. #ifdef FW_BUILD_WIN
  24. #include <Windows.h>
  25. #endif
  26.  
  27. #if FW_LIB_EXPORT_PRAGMAS
  28. #pragma lib_export on
  29. #endif
  30.  
  31. //========================================================================================
  32. // CLASS FW_CDebugStream
  33. //========================================================================================
  34.  
  35. class FW_CLASS_ATTR FW_CDebugStream
  36. {
  37. public:
  38.     typedef FW_CDebugStream& (*Manipulator)(FW_CDebugStream &);
  39.  
  40.     friend FW_FUNC_ATTR FW_CDebugStream& EndLine(FW_CDebugStream &);
  41.  
  42.     FW_CDebugStream();
  43.     virtual ~FW_CDebugStream();
  44.         // Destructor
  45.     
  46.     virtual FW_CDebugStream &Write(const void *data, size_t size) = 0;
  47.         // Does the raw write of the data without any data separator
  48.     
  49.     FW_CDebugStream &WriteChunk(const void *data, size_t size);
  50.         // Write raw data with a data separator
  51.  
  52.     FW_CDebugStream &operator<<(Manipulator function);
  53.         // Execute the manipulator
  54.  
  55.     
  56.     FW_CDebugStream &operator<<(const char *string);
  57.         // Write null terminated char string
  58.         
  59.     FW_CDebugStream &operator<<(const signed char *string);
  60.         // Write null terminated string
  61.         
  62.     FW_CDebugStream &operator<<(const unsigned char *string);
  63.         // Write null terminated string
  64.         
  65.  
  66.     FW_CDebugStream &operator<<(char c);
  67.         // Write character
  68.  
  69.     FW_CDebugStream &operator<<(signed char c);
  70.         // Write signed character
  71.  
  72.     FW_CDebugStream &operator<<(unsigned char c);
  73.         // Write unsigned character
  74.  
  75.     FW_CDebugStream &operator<<(short n);
  76.         // Write short
  77.  
  78.     FW_CDebugStream &operator<<(int n);
  79.         // Write int
  80.  
  81.     FW_CDebugStream &operator<<(long n);
  82.         // Write long
  83.  
  84.     FW_CDebugStream &operator<<(unsigned short n);
  85.         // Write unsigned short
  86.  
  87.     FW_CDebugStream &operator<<(unsigned n);
  88.         // Write unsigned
  89.  
  90.     FW_CDebugStream &operator<<(unsigned long n);
  91.         // Write unsigned long
  92.  
  93.     FW_CDebugStream &operator<<(void *);
  94.         // Write address in hex
  95.  
  96. protected:
  97.     FW_CDebugStream & WriteBase10Number(long n);
  98.         // Write long in base 10
  99.  
  100.     FW_CDebugStream & WriteBase16Number(unsigned long n);
  101.         // Write unsigned long in base 16
  102.  
  103. private:
  104.     FW_CDebugStream(const FW_CDebugStream& debugStream);
  105.     FW_CDebugStream& operator=(const FW_CDebugStream& debugStream);
  106.         // Don't copy instances of this class.
  107. };
  108.  
  109.  
  110. inline FW_CDebugStream &FW_CDebugStream::operator<<(Manipulator function)
  111. {
  112.     return function(*this);
  113. }
  114.  
  115. inline FW_CDebugStream & FW_CDebugStream::operator<<(const char *string)
  116. {
  117.     return operator<<((const signed char *) string);
  118. }
  119.  
  120. inline FW_CDebugStream & FW_CDebugStream::operator<<(const unsigned char *string)
  121. {
  122.     return operator<<((const signed char *) string);
  123. }
  124.  
  125. inline FW_CDebugStream & FW_CDebugStream::operator<<(char c)
  126. {
  127.     return operator<<((signed char) c);
  128. }
  129.  
  130. inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned char c)
  131. {
  132.     return operator<<((signed char) c);
  133. }
  134.  
  135. inline FW_CDebugStream & FW_CDebugStream::operator<<(short n)
  136. {
  137.     return operator<<((long) n);
  138. }
  139.  
  140. inline FW_CDebugStream & FW_CDebugStream::operator<<(int n)
  141. {
  142.     return operator<<((long) n);
  143. }
  144.  
  145. inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned short n)
  146. {
  147.     return operator<<((unsigned long) n);
  148. }
  149.  
  150. inline FW_CDebugStream & FW_CDebugStream::operator<<(unsigned n)
  151. {
  152.     return operator<<((unsigned long) n);
  153. }
  154.  
  155.  
  156. //========================================================================================
  157. // CLASS EndLine
  158. //========================================================================================
  159.  
  160. FW_FUNC_ATTR FW_CDebugStream&  EndLine(FW_CDebugStream &);
  161.     // Output end of line character or characters depending on platform
  162.  
  163. //========================================================================================
  164. // CLASS FW_CBufferDebugStream
  165. //========================================================================================
  166.  
  167. class FW_CLASS_ATTR FW_CBufferDebugStream : public FW_CDebugStream
  168. {
  169. public:
  170.     virtual ~FW_CBufferDebugStream();
  171.     FW_CBufferDebugStream(void * buffer, size_t bufferSize);
  172.         // Constructor
  173.     
  174.     virtual FW_CDebugStream &Write(const void *data, size_t size);
  175.         // Write data
  176.  
  177. private:
  178.     const void * fBuffer;
  179.         // FW_SPlatformPoint to data buffer
  180.  
  181.     const size_t fBufferSize;
  182.         // Size of buffer
  183.  
  184.     size_t fPosition;
  185.         // Next position to write to in buffer
  186.  
  187.     FW_CBufferDebugStream(const FW_CBufferDebugStream& debugStream);
  188.     FW_CBufferDebugStream& operator=(const FW_CBufferDebugStream& debugStream);
  189.         // Don't copy instances of this class.
  190. };
  191.  
  192.  
  193. //========================================================================================
  194. // CLASS FW_CNullDebugStream
  195. //========================================================================================
  196.  
  197. class FW_CLASS_ATTR FW_CNullDebugStream : public FW_CDebugStream
  198. {
  199. public:
  200.     FW_CNullDebugStream();
  201.     virtual ~FW_CNullDebugStream();
  202.  
  203.     virtual FW_CDebugStream &Write(const void *data, size_t size);
  204.         // Write data
  205.  
  206. private:
  207.     FW_CNullDebugStream(const FW_CNullDebugStream& debugStream);
  208.     FW_CNullDebugStream& operator=(const FW_CNullDebugStream& debugStream);
  209.         // Don't copy instances of this class.
  210. };
  211.  
  212.  
  213. //========================================================================================
  214. // CLASS FW_CFileDebugStream
  215. //========================================================================================
  216.  
  217. class FW_CLASS_ATTR FW_CFileDebugStream : public FW_CDebugStream
  218. {
  219. public:
  220.     FW_CFileDebugStream(char *fileName);
  221.         // Constructor
  222.     
  223.     ~FW_CFileDebugStream();
  224.         // Destructor
  225.     
  226.     virtual FW_CDebugStream &Write(const void *data, size_t size);
  227.         // Write data
  228.  
  229. private:
  230. #ifdef FW_BUILD_MAC
  231.     short fMacFileNumber;
  232. #endif
  233. #ifdef FW_BUILD_WIN
  234.     HFILE fWinFileHandle;
  235. #endif
  236.  
  237.     FW_CFileDebugStream(const FW_CFileDebugStream& debugStream);
  238.     FW_CFileDebugStream& operator=(const FW_CFileDebugStream& debugStream);
  239.         // Don't copy instances of this class.
  240. };
  241.  
  242. #if FW_LIB_EXPORT_PRAGMAS
  243. #pragma lib_export off
  244. #endif
  245.  
  246. #endif
  247.